package org.jwcloud.project.module.zx.timingSz.service;

import java.util.List;
import java.util.Map;

import org.jwcloud.project.module.zx.common.Resp;

import com.jw.mid.mm.comm.common.json.Response;
import com.jw.mid.mm.comm.common.pagination.PageListSlice;
import com.jw.mid.mm.comm.common.pagination.Pagination;
import org.jwcloud.project.module.zx.common.service.RptUtService;
import org.jwcloud.project.module.zx.timingSz.service.repository.RptTimingSzRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class RptTimingSzServiceImpl implements RptTimingSzService {

    @Autowired
    public RptTimingSzRepository rptTimingSzRepository;

    @Autowired
    public RptUtService rptUtService;


    @Override
    public Resp<List<Map<String, String>>> queryTemplateList(Map param) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public Resp<Response<PageListSlice>> queryTemplateList(Pagination pagination, Map param) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public Resp<Object> doTemplateUpdate(Map param) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public Resp<Response<PageListSlice>> queryTaskInfoListById(Pagination pagination, Map param) {
        return Resp.success(
                this.rptUtService.findPagi(
                        pagination,
                        param,
                        rptTimingSzRepository.queryTaskInfo(param),
                        rptTimingSzRepository.queryTaskInfo_total(param)
                ));
    }

    @Override
    public Resp<Object> updateTiming(Map param) {
        int x = rptTimingSzRepository.updateTimeSetting(param);
        if (x == 0) {
            return Resp.error("第二次预警时间必须大于第一次");
        } else {
            return Resp.success(x);
        }
    }

}
